package ae.pcfc.etks.cld.to.web.model;


import javax.servlet.http.HttpServletRequest;

import org.springframework.context.annotation.Scope;
import org.springframework.context.annotation.ScopedProxyMode;
import org.springframework.stereotype.Component;

@Component(value="requestVariablesBean")
@Scope(value="request", proxyMode=ScopedProxyMode.TARGET_CLASS)
public class RequestVariablesBean {

	private String contextPath;
	private String requestedHost;
	private Throwable exceptionStore;
	private boolean isAjaxRequest;

	public String getContextPath() {
		return contextPath;
	}
	public void setContextPath(String contextPath) {
		this.contextPath = contextPath;
	}
	public String getRequestedHost() {
		return requestedHost;
	}
	public void setRequestedHost(String requestedHost) {
		this.requestedHost = requestedHost;
	}
	public Throwable getExceptionStore() {
		return exceptionStore;
	}
	public void setExceptionStore(Throwable exceptionStore) {
		this.exceptionStore = exceptionStore;
	}
	public boolean isAjaxRequest() {
		return isAjaxRequest;
	}
	public void setAjaxRequest(boolean isAjaxRequest) {
		this.isAjaxRequest = isAjaxRequest;
	}
	
	public static boolean isAjaxRequest(HttpServletRequest request){
		return "XMLHttpRequest".equalsIgnoreCase(request.getHeader("X-Requested-With"));
	}
	
	
}
